﻿<?php

include("..\webservice.php");
include("..\mysql.php");
include("..\ZeusObjects.php");

// Webszervíz hívás eredménye
//
$res = new WebResult();

try 
{
  // Parameters
	$page = $_GET['page'];
	  
  $login = $_GET['login'];
  $password = base64_decode($_GET['password']);
  
  $lang = new Language('en_US');
  
  if (isset($_GET['lang']))
  	$lang = new Language($_GET['lang']);
    

  // Connect to MySql databse
  $conn = sql_connect($lang->Lang);
  
  // Login command    
  $sql = "CALL spZeusUserLogin(:login, :password)";
    
  $par = array();
  array_push($par, new SqlParam(':login', $login));
  array_push($par, new SqlParam(':password', $password));
    
  $rows = sql_execute($conn, $sql, $par);          
    
  // Adatsorok feldolgozása
  foreach ($rows as $row) 
  {  
    $obj = new ZeusUser();
    $obj->ID = $row['ID'];
    $obj->Name = $row['Name'];

    array_push($res->Result, $obj);
  }
      
  // Adatbázis bezárás
  $conn = null;

  // # Az eredmény kisorosítása
  // #
  echo json_encode($res);
} 
catch (Exception $e) 
{
  // # Hibakezelés
  // #
  $res->ErrorCode = 1;
  $res->ErrorText = $e->getMessage();
  
  echo json_encode($res);
}

?>